<?php

namespace App\HttpController\Api;

use App\Core\Output;
use App\Logic\UploadService;
use EasySwoole\Http\Message\Status;


class Common extends BaseController {
    public function __construct()
    {
        $this->_checkAuth = false;
        parent::__construct();
    }

    public function skip()
    {
        $data = [];
        $result = (new Output())->setStatusCode(Status::CODE_OK)->setMsg('success')->setData($data);
        return $this->writeJsonByOutput($result);
    }

    public function upload(){
        //获取图片
        $request = $this->request();
        $file = $request->getUploadedFile('file');

        $uploadImg = new UploadService();
        $path = $uploadImg->upload($file);

        return $this->writeJsonByOutput($path);
    }

    public function date(){
        $data = [
            'startDate' => date('Y-m-1'),
            'endDate' => date('Y-m-d'),
        ];
        $result = (new Output())->setStatusCode(Status::CODE_OK)->setMsg('success')->setData($data);
        return $this->writeJsonByOutput($result);
    }

}
